package cn.code;

public class ConsuA implements SellSumMoney{
    @Override
    public int sellMoney(Integer appleNum, Integer strawberryNum, Integer mangoNum, boolean biaozhi) {
        //标志是否有打折活动
        Shop shop = new Shop(biaozhi);

        //苹果
        Integer apple = shop.getApple();
        //草莓
        Integer strawberry = shop.getStrawberry();
        //芒果
        Integer mango = shop.getMango();

        Integer sum01 = appleNum*apple;
        Integer sum02 = strawberry * strawberryNum;

        //打折
        boolean discount = shop.getDiscount();

        if(discount){
            double sum03= (mango*mangoNum)*0.8;
            int sum = sum(sum01, sum02, (int) sum03);
            if(sum>=100){
                return  descBy10(sum);
            }else {
                return sum;
            }
        }else {
            Integer sum03= mango*mangoNum;
            return  sum(sum01,sum02,sum03);
        }
    }

    private int sum (Integer a,Integer b, Integer c){
        // 商品总价
        return a+b+c;
    }

    private Integer descBy10(Integer desc){
        //促销，满一百减10
        return desc -10;
    }
}
